home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
187_01
/
utoa.c
< prev
next >
Wrap
Text File
|
1985-12-29
|
1KB
|
31 lines
/*@*****************************************************/
/*@ */
/*@ utoa - convert unsigned integer to ascii. */
/*@ Very useful to prevent loading of printf */
/*@ and the 2-8K of follow-ons. */
/*@ */
/*@ Usage: utoa(num, buffer); */
/*@ where num is an unsigned integer. */
/*@ buffer is a char area large enough to */
/*@ to hold the resulting string. */
/*@ */
/*@ Returns a pointer to the buffer. This allows */
/*@ nesting of puts(utoa(n, buffer)); variety. */
/*@ */
/*@*****************************************************/
utoa(n,s) /* convert n to characters in s */
char s[];
unsigned n;
{
int i;
i = 0;
do { /* generate digits in reverse order */
s[i++] = n % 10 + '0'; /* get next digit */
} while ((n /= 10) > 0); /* delete it */
s[i] = '\0';
reverse(s);
return s;
}